from flask_login import UserMixin

from Config import db, login_manager



@login_manager.user_loader
def user_loader(id):
    return User.query.filter_by(id=id).first()


class User(db.Model, UserMixin):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), unique=False)
    password = db.Column(db.String(255), unique=False)
    e_mail = db.Column(db.String(50), unique=False)

    def __init__(self, username, password, e_mail):
        self.username = username
        self.e_mail = e_mail
        self.password = password

    def get_id(self):
        return self.id


if __name__ == '__main__':
    db.create_all()
